#ifndef LOGIN_H
#define LOGIN_H
#include <QObject>
#include <QDebug>

#define GAME           "GAME"

class Login: public QObject
{
    Q_OBJECT
    //枚举类型注册
    Q_ENUMS(Color)
    //属性声明
    Q_PROPERTY(Color color READ getColor WRITE setColor NOTIFY colorChanged)
    Q_PROPERTY(QString deviceId READ getDeviceId WRITE setDeviceId)
    Q_PROPERTY(QString password READ getPassword WRITE setPassword)
public:
    Login(QObject *parent) : QObject(parent){ qDebug() << "Welcome.";}
    //枚举
    enum Color
    {
      RED,
      BLUE,
      BLACK
    };
    //成员函数
    Q_INVOKABLE void show(){  qDebug() << "show() is called."; }
    Q_INVOKABLE void login(){ qDebug() << "login() is called."; }
    Color getColor() const{return m_color;}
    void setColor(const Color& color){m_color = color;emit colorChanged();}
    QString getDeviceId() {return deviceId;}
    void setDeviceId(QString id) {deviceId = id;}
    QString getPassword() {return password;}
    void setPassword(QString pw) {password = pw;}

public slots:
    void doSomething(Color color)
    {
        qDebug() << "dosomething() is called " << color;
    }
signals:
    void begin();
    void colorChanged();
private:
    Color m_color;//属性
    QString deviceId;
    QString password;
};

#endif // LOGIN_H
